package com.flydog.taskManager.repository;

import com.flydog.taskManager.dto.ProcessStatus;
import com.flydog.taskManager.entity.PhasedTask;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.Calendar;
import java.util.List;

/**
 * @author Cao
 * @description 阶段性工作数据仓库
 * @create 2021-05-10
 */
public interface PhasedTaskRepository extends JpaRepository<PhasedTask, Long>, JpaSpecificationExecutor<PhasedTask> {
    List<PhasedTask> findByEndIsLessThanEqualAndProcessStatusEquals(Calendar end, ProcessStatus processStatus);

    Page<PhasedTask> findByEndBetweenAndUserId(Calendar begin, Calendar end, Long userId, Pageable pageable);

    List<PhasedTask> findByEndBetweenAndUserId(Calendar begin, Calendar end, Long userId);

    Page<PhasedTask> findByBeginBetweenAndUserId(Calendar begin, Calendar end, Long userId, Pageable pageable);

    List<PhasedTask> findByBeginBetweenAndUserId(Calendar begin, Calendar end, Long userId);

    int countByBeginBetweenAndUserId(Calendar beginStart, Calendar beginEnd, Long userId);

    int countByEndBetweenAndUserId(Calendar endStart, Calendar endEnd, Long userId);

    List<PhasedTask> findByParentId (Long id);

    List<PhasedTask> findByLevelAndUserIdOrderByBeginDesc(int level, Long userId);



}
